package com.peng.controller;

import com.peng.pojo.Link;
import com.peng.service.LinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class LinkController {
    @Autowired
    private LinkService linkService;

    @GetMapping("/admin/getLink")
    public List<Link> getLink() {
        return linkService.selectAll();
    }

    @PostMapping("/admin/addLink")
    public boolean addLink(Link link) {
        return linkService.addLink(link);
    }

    @PostMapping("/admin/updateLink")
    public boolean updateLink(Link link) {
        return linkService.updateLink(link);
    }

    @GetMapping("/admin/deleteLink")
    public boolean deleteLink(int id) {
        return linkService.deleteLinkById(id);
    }
}
